home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d938.lha
/
Angie
/
AngieGUI.mod
< prev
next >
Wrap
Text File
|
1993-12-20
|
16KB
|
442 lines
MODULE AngieGUI;
(*
* Source generated with OG 38.02 (18.6.93) by Stefan Kurtz - Original Version by Thomas Igracki
* OG is based on GenOberon V1.0 by Kai Bolay & Jan van den Baard
* GenOberon is based on internal GenOberon by Kai Bolay
* internal GenOberon is based on GenC by Jan van den Baard
*
* GUI Designed by : fSchwarz
*
* Source heavily modified, optimized & adapted for V39 Intuition 'best look'
* & V39 interface modules by fSchwarz
*)
IMPORT
e: Exec, I: Intuition, gt: GadTools, g: Graphics, u: Utility, y: SYSTEM,
b: BlackMagic, ie: InputEvent, st: Strings;
CONST
AngieHotKeys * = "E\000XYBPKSHNALCITDUOWR";
GDdefinition * = 0;
GDhotkeys * = 1;
GDpri * = 2;
GDdelay * = 3;
GDstable * = 4;
GDpop * = 5;
GDkeyact * = 6;
GDincwintaskpri * = 7;
GDhuntalways * = 8;
GDhuntwintofront * = 9;
GDtype * = 10;
GDshufflebdrop * = 11;
GDscrsteps * = 12;
GDwinsteps * = 13;
GDhuntdefpub * = 14;
GDadd * = 15;
GDdel * = 16;
GDup * = 17;
GDdown * = 18;
GDshufflepat * = 19;
GDattrs * = 20;
(* menuLabels *)
MNsave * = 4000H;
MNabout * = 4001H;
MNhide * = 4002H;
MNquit * = 4003H;
CONST
AngieCNT = 21;
AngieLeft = 5;
AngieTop = 12;
AngieWidth = 631;
AngieHeight = 174;
VAR
Scr-: I.ScreenPtr;
VisualInfo-: e.APTR;
AngieWnd-: I.WindowPtr;
AngieGList-: I.GadgetPtr;
AngieGadgets*: ARRAY AngieCNT OF I.GadgetPtr;
AngieMenus-: I.MenuPtr;
AngieZoom-: ARRAY 4 OF INTEGER;
Font-: g.TextAttrPtr;
Attr-: g.TextAttr;
FontX, FontY: INTEGER;
OffX, OffY: INTEGER;
TYPE
attrs0LArray = ARRAY 9 OF e.STRPTR;
CONST
attrs0Labels = attrs0LArray (
y.ADR ("--------,--------,--------"),
y.ADR ("WinFront,--------,--------"),
y.ADR ("--------,NoScrAct,--------"),
y.ADR ("WinFront,NoScrAct,--------"),
y.ADR ("--------,--------,Repeatbl"),
y.ADR ("WinFront,--------,Repeatbl"),
y.ADR ("--------,NoScrAct,Repeatbl"),
y.ADR ("WinFront,NoScrAct,Repeatbl"),
NIL);
VAR
hotkeys0List*: e.MinList;
TYPE
AngieMArray = ARRAY 8 OF gt.NewMenu;
CONST
AngieNewMenu = AngieMArray (
gt.title, y.ADR ("Project"), NIL, {}, y.VAL (LONGSET, 0), -1,
gt.item, y.ADR ("Save Settings"), y.ADR ("S"), {}, y.VAL (LONGSET, 0), MNsave,
gt.item, gt.barLabel, NIL, {}, LONGSET {}, -1,
gt.item, y.ADR ("About..."), y.ADR ("?"), {}, y.VAL (LONGSET, 0), MNabout,
gt.item, gt.barLabel, NIL, {}, LONGSET {}, -1,
gt.item, y.ADR ("Hide"), y.ADR ("H"), {}, y.VAL (LONGSET, 0), MNhide,
gt.item, y.ADR ("Quit"), y.ADR ("Q"), {}, y.VAL (LONGSET, 0), MNquit,
gt.end, NIL, NIL, {}, LONGSET {}, -1);
TYPE
AngieGTypesArray = ARRAY AngieCNT OF INTEGER;
CONST
AngieGTypes = AngieGTypesArray (
gt.stringKind,
gt.listViewKind,
gt.sliderKind,
gt.sliderKind,
gt.sliderKind,
gt.checkBoxKind,
gt.checkBoxKind,
gt.checkBoxKind,
gt.checkBoxKind,
gt.checkBoxKind,
gt.stringKind,
gt.checkBoxKind,
gt.sliderKind,
gt.sliderKind,
gt.checkBoxKind,
gt.buttonKind,
gt.buttonKind,
gt.buttonKind,
gt.buttonKind,
gt.stringKind,
gt.cycleKind
);
CONST
rawCrsrUp * = 04CH;
rawCrsrDown * = 04DH;
VAR
hotnames *: UNTRACED POINTER TO ARRAY MAX (INTEGER)-1 OF b.LStrPtr;
PROCEDURE EdHookProc (hook: u.HookPtr; sgworkobj: e.APTR; msg: e.APTR): LONGINT;
VAR
sgwork: I.SGWorkPtr;
cmd : UNTRACED POINTER TO LONGINT;
i,l : INTEGER;
wstr : b.LStrPtr;
(* $StackChk- !!executed in Intuition context!! *)
BEGIN
sgwork := sgworkobj; cmd := msg;
wstr := sgwork.workBuffer;
IF cmd^ # I.sghKey THEN RETURN e.false; END;
IF sgwork.iEvent.class # ie.rawkey THEN RETURN e.false; END;
CASE sgwork.iEvent.code OF
rawCrsrUp, rawCrsrDown:
IF sgwork.gadget = AngieGadgets[GDtype] THEN
IF hotnames # NIL THEN
l := 0;
WHILE (hotnames[l] # NIL) DO INC (l); END;
IF l > 0 THEN
i := 0;
WHILE (hotnames[i] # NIL) & (u.Stricmp (wstr^, hotnames[i]^) # 0) DO
INC (i);
END;
IF hotnames [i] = NIL THEN DEC (i); END;
CASE sgwork.iEvent.code OF
rawCrsrDown:
INC (i, 1); IF i >= l THEN i := 0; END; |
rawCrsrUp:
DEC (i, 1); IF i < 0 THEN i := l-1; END;
ELSE END;
IF i = l-1 THEN
COPY ("", wstr^);
ELSE
COPY (hotnames[i]^, wstr^);
END;
sgwork.numChars := SHORT (st.Length (wstr^));
IF sgwork.bufferPos > sgwork.numChars THEN
sgwork.bufferPos := sgwork.numChars;
END;
sgwork.actions := LONGSET {I.sgaUse, I.sgaRedisplay};
sgwork.code := sgwork.iEvent.code;
RETURN e.true;
END;
END;
ELSIF sgwork.gadget = AngieGadgets[GDdefinition] THEN
sgwork.actions := LONGSET{I.sgaEnd};
sgwork.code := sgwork.iEvent.code;
RETURN e.true;
END;
ELSE END;
IF sgwork.code = 27 (* ESC *) THEN
sgwork.actions := LONGSET{I.sgaEnd};
RETURN e.true;
END;
RETURN e.false;
END EdHookProc;
(* $StackChk= *)
TYPE
AngieNGadArray = ARRAY AngieCNT OF gt.NewGadget;
CONST
AngieNGad = AngieNGadArray (
8, 92, 314, 14, NIL, NIL, GDdefinition, LONGSET {} ,NIL, NIL,
8, 15, 314, 80, y.ADR ("_Edit hotkeys"), NIL, GDhotkeys, LONGSET {gt.placeTextAbove} ,NIL, NIL,
441, 160, 137, 11, y.ADR ("C_X priority"), NIL, GDpri, LONGSET {gt.placeTextLeft} ,NIL, NIL,
441, 118, 137, 11, y.ADR ("Snoop dela_y"), NIL, GDdelay, LONGSET {gt.placeTextLeft} ,NIL, NIL,
441, 104, 137, 11, y.ADR ("Sta_ble time"), NIL, GDstable, LONGSET {gt.placeTextLeft} ,NIL, NIL,
337, 90, 26, 11, y.ADR ("_Pop GUI on startup"), NIL, GDpop, LONGSET {gt.placeTextRight} ,NIL, NIL,
337, 48, 26, 11, y.ADR ("_Key screen activation"), NIL, GDkeyact, LONGSET {gt.placeTextRight} ,NIL, NIL,
337, 62, 26, 11, y.ADR ("Rai_se Active WinTask's Pri"), NIL, GDincwintaskpri, LONGSET {gt.placeTextRight} ,NIL, NIL,
337, 6, 26, 11, y.ADR ("_Hunt always"), NIL, GDhuntalways, LONGSET {gt.placeTextRight} ,NIL, NIL,
337, 20, 26, 11, y.ADR ("Hu_nt on wintofront hotkeys"), NIL, GDhuntwintofront, LONGSET {gt.placeTextRight} ,NIL, NIL,
64, 97, 258, 14, y.ADR ("_Action"), NIL, GDtype, LONGSET {gt.placeTextLeft} ,NIL, NIL,
337, 76, 26, 11, y.ADR ("Shuff_le backdrop windows"), NIL, GDshufflebdrop, LONGSET {gt.placeTextRight} ,NIL, NIL,
441, 132, 137, 11, y.ADR ("S_creen steps"), NIL, GDscrsteps, LONGSET {gt.placeTextLeft} ,NIL, NIL,
441, 146, 137, 11, y.ADR ("W_indow steps"), NIL, GDwinsteps, LONGSET {gt.placeTextLeft} ,NIL, NIL,
337, 34, 26, 11, y.ADR ("Hun_t: set default public screen"), NIL, GDhuntdefpub, LONGSET {gt.placeTextRight} ,NIL, NIL,
8, 127, 77, 13, y.ADR ("A_DD"), NIL, GDadd, LONGSET {gt.placeTextIn} ,NIL, NIL,
87, 127, 77, 13, y.ADR ("(DEL)"), NIL, GDdel, LONGSET {gt.placeTextIn} ,NIL, NIL,
166, 127, 77, 13, y.ADR ("_UP"), NIL, GDup, LONGSET {gt.placeTextIn} ,NIL, NIL,
245, 127, 77, 13, y.ADR ("D_OWN"), NIL, GDdown, LONGSET {gt.placeTextIn} ,NIL, NIL,
8, 157, 314, 14, y.ADR ("_Window shuffle pattern"), NIL, GDshufflepat, LONGSET {gt.placeTextAbove} ,NIL, NIL,
56, 112, 266, 13, y.ADR ("Att_rs"), NIL, GDattrs, LONGSET {gt.placeTextLeft} ,NIL, NIL
);
TYPE
AngieGTagsArray = ARRAY 175 OF u.Tag;
CONST
AngieGTags = AngieGTagsArray (
gt.stMaxChars, 255, gt.stEditHook, NIL, u.done,
gt.lvShowSelected, 1, gt.underscore, 95, u.done,
gt.slMin, -128, gt.slMax, 127, gt.slLevel, 127, gt.slMaxLevelLen, 20, gt.slLevelFormat, y.ADR ("%ld"), gt.slLevelPlace, LONGSET {gt.placeTextRight}, I.pgaFreedom, I.lorientHoriz, I.gaRelVerify, I.LTRUE, gt.underscore, 95, u.done,
gt.slMin, 10, gt.slMax, 1000, gt.slLevel, 1000, gt.slMaxLevelLen, 20, gt.slLevelFormat, y.ADR ("%ld"), gt.slLevelPlace, LONGSET {gt.placeTextRight}, I.pgaFreedom, I.lorientHoriz, I.gaRelVerify, I.LTRUE, gt.underscore, 95, u.done,
gt.slMin, -1, gt.slMax, 1000, gt.slLevel, 1000, gt.slMaxLevelLen, 20, gt.slLevelFormat, y.ADR ("%ld"), gt.slLevelPlace, LONGSET {gt.placeTextRight}, I.pgaFreedom, I.lorientHoriz, I.gaRelVerify, I.LTRUE, gt.underscore, 95, u.done,
gt.cbScaled, I.LTRUE, gt.underscore, 95, u.done,
gt.cbScaled, I.LTRUE, gt.underscore, 95, u.done,
gt.cbScaled, I.LTRUE, gt.underscore, 95, u.done,
gt.cbScaled, I.LTRUE, gt.underscore, 95, u.done,
gt.cbScaled, I.LTRUE, gt.underscore, 95, u.done,
gt.underscore, 95, gt.stMaxChars, 255, gt.stEditHook, NIL, I.stringaJustification, LONGSET{I.stringCenter}, u.done,
gt.cbScaled, I.LTRUE, gt.underscore, 95, u.done,
gt.slMin, 1, gt.slMax, 50, gt.slLevel, 50, gt.slMaxLevelLen, 20, gt.slLevelFormat, y.ADR ("%ld"), gt.slLevelPlace, LONGSET {gt.placeTextRight}, I.pgaFreedom, I.lorientHoriz, I.gaRelVerify, I.LTRUE, gt.underscore, 95, u.done,
gt.slMin, 1, gt.slMax, 50, gt.slLevel, 50, gt.slMaxLevelLen, 20, gt.slLevelFormat, y.ADR ("%ld"), gt.slLevelPlace, LONGSET {gt.placeTextRight}, I.pgaFreedom, I.lorientHoriz, I.gaRelVerify, I.LTRUE, gt.underscore, 95, u.done,
gt.cbScaled, I.LTRUE, gt.underscore, 95, u.done,
gt.underscore, 95, u.done,
gt.underscore, 95, u.done,
gt.underscore, 95, u.done,
gt.underscore, 95, u.done,
gt.underscore, 95, gt.stMaxChars, 255, gt.stEditHook, NIL, I.stringaJustification, LONGSET{I.stringCenter}, u.done,
gt.cyLabels, y.ADR (attrs0Labels[0]), gt.underscore, 95, u.done
);
PROCEDURE ComputeX (value: INTEGER): INTEGER;
BEGIN
RETURN ((FontX * value) + 4 ) DIV 8;
END ComputeX;
PROCEDURE ComputeY (value: INTEGER): INTEGER;
BEGIN
RETURN ((FontY * value) + 4 ) DIV 8;
END ComputeY;
PROCEDURE ComputeFont (width, height: INTEGER);
BEGIN
Font := y. ADR (Attr);
Font^.name := Scr^.rastPort.font^.message.node.name;
FontY := Scr^.rastPort.font^.ySize;
Font^.ySize := FontY;
FontX := Scr^.rastPort.font^.xSize;
OffX := Scr^.wBorLeft;
OffY := Scr^.rastPort.txHeight + Scr^.wBorTop + 1;
IF (width # 0) AND (height # 0) AND
(ComputeX (width) + OffX + Scr^.wBorRight > Scr^.width) OR
(ComputeY (height) + OffY + Scr^.wBorBottom > Scr^.height) THEN
Font^.name := y.ADR ("topaz.font");
Font^.ySize := 8;
FontY := Font^.ySize;
FontX := Font^.ySize;
END;
END ComputeFont;
PROCEDURE SetupScreen* (pub: ARRAY OF CHAR): INTEGER; (* $CopyArrays- *)
BEGIN
IF pub#"" THEN Scr:=I.LockPubScreen(pub) ELSE Scr:=I.LockPubScreen(NIL) END;
IF Scr = NIL THEN RETURN 1 END;
ComputeFont (0, 0);
VisualInfo := gt.GetVisualInfo (Scr, u.done);
IF VisualInfo = NIL THEN RETURN 2 END;
RETURN 0;
END SetupScreen;
PROCEDURE CloseDownScreen*;
BEGIN
IF VisualInfo # NIL THEN
gt.FreeVisualInfo (VisualInfo);
VisualInfo := NIL;
END;
IF Scr # NIL THEN
I.UnlockPubScreen (NIL, Scr);
Scr := NIL;
END;
END CloseDownScreen;
VAR
EdHook: u.Hook;
PROCEDURE CreateAngieGadgets* (): INTEGER;
TYPE
TagArrayPtr = u.TagListPtr;
VAR
ng: gt.NewGadget;
gad: I.GadgetPtr;
tmp: u.TagItemPtr;
help: TagArrayPtr;
ret, lc, tc, lvc, offx, offy: INTEGER;
BEGIN
offx := Scr^.wBorLeft; offy := Scr^.wBorTop + Scr^.rastPort.txHeight + 1;
ComputeFont (AngieWidth, AngieHeight);
gad := gt.CreateContext (AngieGList);
IF gad = NIL THEN RETURN 1 END;
lc := 0; tc := 0; lvc := 0;
WHILE lc < AngieCNT DO
ng := AngieNGad[lc];
ng.visualInfo := VisualInfo;
ng.textAttr := Font;
ng.leftEdge := OffX + ComputeX (ng.leftEdge);
ng.topEdge := OffY + ComputeY (ng.topEdge);
ng.width := ComputeX (ng.width);
ng.height := ComputeY (ng.height);
hotkeys0List.head := y.ADR (hotkeys0List.tail);
hotkeys0List.tail := NIL;
hotkeys0List.tailPred := y.ADR (hotkeys0List.head);
help := u.CloneTagItems (y.VAL (TagArrayPtr, y.ADR (AngieGTags[tc]))^);
IF help = NIL THEN RETURN 8 END;
IF AngieGTypes[lc] = gt.listViewKind THEN
tmp := u.FindTagItem (gt.lvShowSelected, help);
IF tmp # NIL THEN
IF tmp^.data # NIL THEN tmp^.data := gad END;
END;
END; (* IF *)
CASE lc OF
GDdefinition, GDshufflepat, GDtype:
tmp := u.FindTagItem (gt.stEditHook, help);
IF tmp # NIL THEN
u.InitHook (y.ADR (EdHook), EdHookProc);
tmp^.data := y.ADR (EdHook);
END;
ELSE END;
gad := gt.CreateGadgetA (AngieGTypes[lc], gad, ng, help^);
u.FreeTagItems (help);
IF gad = NIL THEN RETURN 2 END;
AngieGadgets[lc] := gad;
WHILE AngieGTags[tc] # u.done DO INC (tc, 2) END;
INC (tc);
INC (lc);
END; (* WHILE *)
RETURN 0;
END CreateAngieGadgets;
PROCEDURE OpenAngieWindow* (createGads: BOOLEAN): INTEGER;
VAR
offx, offy, ret: INTEGER;
wleft, wtop, ww, wh: INTEGER;
rect: g.Rectangle;
BEGIN
IF ~b.VisibleOfScreen (Scr, rect) THEN END;
wleft := rect.minX+AngieLeft; wtop := rect.minY+AngieTop;
ComputeFont (AngieWidth, AngieHeight);
ww := ComputeX (AngieWidth);
wh := ComputeY (AngieHeight);
IF wleft + ww + OffX + Scr^.wBorRight > Scr^.width THEN
wleft := Scr^.width - ww;
END;
IF wtop + wh + OffY + Scr^.wBorBottom > Scr^.height THEN
wtop := Scr^.height - wh;
END;
IF createGads THEN
ret := CreateAngieGadgets(); IF ret # 0 THEN RETURN ret END;
END;
AngieMenus := gt.CreateMenus (AngieNewMenu, gt.mnFrontPen, 0, u.done);
IF AngieMenus = NIL THEN RETURN 3 END;
IF NOT gt.LayoutMenus (AngieMenus, VisualInfo, gt.mnNewLookMenus, I.LTRUE, u.done) THEN RETURN 4 END;
AngieZoom[0] := rect.minX;
AngieZoom[1] := rect.minY+1;
AngieZoom[2] := g.TextLength (y.ADR (Scr^.rastPort), "Angie 1.0 ", 10) + 80;
AngieZoom[3] := Scr^.wBorTop + Scr^.rastPort.txHeight + 1;
AngieWnd := I.OpenWindowTagsA ( NIL,
I.waLeft, wleft,
I.waTop, wtop,
I.waWidth, ww + OffX + Scr^.wBorRight,
I.waHeight, wh + OffY + Scr^.wBorBottom,
I.waIDCMP, gt.stringIDCMP+gt.listViewIDCMP+gt.sliderIDCMP+gt.checkBoxIDCMP+gt.buttonIDCMP+gt.cycleIDCMP+LONGSET {I.menuPick,I.closeWindow,I.changeWindow,I.refreshWindow, I.vanillaKey, I.rawKey},
I.waFlags, LONGSET {I.newLookMenus,I.windowDrag,I.windowDepth,I.windowClose,I.activate},
I.waTitle, y.ADR ("Angie 1.0 "),
I.waPubScreen, Scr,
I.waZoom, y.ADR (AngieZoom),
I.waGadgets, AngieGList,
I.waAutoAdjust, I.LTRUE,
I.waPubScreenFallBack, I.LTRUE,
u.done);
IF AngieWnd = NIL THEN RETURN 20 END;
IF NOT I.SetMenuStrip (AngieWnd, AngieMenus^) THEN RETURN 5 END;
gt.RefreshWindow (AngieWnd, NIL);
RETURN 0;
END OpenAngieWindow;
PROCEDURE CloseAngieWindow*;
BEGIN
IF AngieMenus # NIL THEN
IF AngieWnd # NIL THEN
I.ClearMenuStrip (AngieWnd);
END;
gt.FreeMenus (AngieMenus);
AngieMenus := NIL;
END;
IF AngieWnd # NIL THEN
I.CloseWindow (AngieWnd);
AngieWnd := NIL;
END;
IF AngieGList # NIL THEN
gt.FreeGadgets (AngieGList);
AngieGList := NIL;
END;
END CloseAngieWindow;
END AngieGUI.